<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>购物车 - 胎大王</title>
	<meta charset="UTF-8">
	{include file='common/head' /}
	<script src="__JS__/cart.js"></script>
	<script src="__JS__/layer/layer.js"></script>
</head>
<body>

<div class="container">
{include file='common/top' /}
	<div class="cart">
		<div class="cart-banner"></div>
		<div class="contai">
			<span class="f-bk30"></span><span class="f-bk10"></span>
			<div class="cart-con">
				<form id="formData" action="/cartSubmit.html" method="post">
					<table id="cartTable" class="table"  valign="middle">
						<tr>
							<th width="180">全选</th>
							<th>商品</th>
							<th width="120" class="f-textc">单价</th>

							<th width="80">数量</th>
							<th width="120">小计</th>
							<th width="80">操作</th>
						</tr>
						{empty name="data"}
						<tr class="cart-info"  valign="top">
							<td colspan="6">
								<div>
									<p>您的购物车还没有添加商品</p>
								</div>
							</td>
						</tr>
						{else /}
						{if condition="$data.code==10004"}
						<tr class="cart-info"  valign="top">
							<td colspan="6">
								<div>
									<p>您的购物车还没有添加商品</p>
								</div>
							</td>
						</tr>
						{elseif condition="$data.code==1004"/}
						<tr class="cart-info"  valign="top">
							<td colspan="6">
								<div>
									<p>您的购物车还没有添加商品</p>
								</div>
							</td>
						</tr>
						{else /}
						{volist name="$data['data']['cartItemArray']" id="vo"}
						<tr class="imfor">
							<td class="pic"><input type='checkbox' name="item[{$vo.productId}]" class="Each"><a target="_blank" {if condition="$vo.type=='deposit'"}href="/depositDetail.html?id={$vo.productId}" {else /}href="/dividendDetail.html?id={$vo.productId}"{/if}><img src="{$vo.image}" alt="{$vo.name}"></a></td>
							<td class="tit"><p><a target="_blank"{if condition="$vo.type=='deposit'"}href="/depositDetail.html?id={$vo.productId}" {else /}href="/dividendDetail.html?id={$vo.productId}"{/if}>{$vo.name}</a></p>商品类型：{if condition="$vo.type=='deposit'"}即时订单商品{else/}分红式订单商品{/if}</td><input type="hidden" value="{$vo.productId}" name='productId' />
							<td class="pices"><p>￥{$vo.price}</p></td>
							<td class="num"><span class="reduc">&nbsp;-&nbsp;</span><input class="numinput" type="text" name='quantity[{$vo.productId}]' value="{$vo.quantity}" /><span class="add">&nbsp;+</span></td>
							<td class="totle">￥{$vo.subtotal}</td>
							<td class="del"><a href="javascript:;" target="_self" data-del='{$vo.productId}'><i class="fa fa-close"></i>删除商品</a></td>
						</tr>						
						{/volist}
						<span class="f-bk30"></span>
						<tr>
							<td colspan="6" >
								<div class="cart-bottom">
									<div>
										<ul>
											<li><label><input type='checkbox' class="checkboxall2"  /> 全选</label>&emsp;&emsp;</li>
											<li><a target="_self"  class="foot_del">删除选中的商品</a>&emsp;&emsp;</li>
										</ul>
									</div>
									<span class="f-bk3"></span>
								</div>
							</td>
						</tr>
						<tr class="cart-bm">
							<td colspan="6">
								<div class="f-fr ">
									<button type="button" class="button-red pure-button submit" style="width:150px;">立即结算</button>
									<span class="f-bk10"></span>
								</div>
								<div class="f-fr jg">商品总价：<span class="amount">￥0</span><span class="fun-red">元</span></div>

							</td>
						</tr>						
						{/if}
						{/empty}
					</table>
				</form>
				<span class="f-bk30"></span>
			</div>
			<span class="f-bk20"></span>
		</div>
	</div>

	{include file='common/foot' /}
</div>
<script>
$(function(){
	//删除当前行
	$(".del").click(function() {
		var that = this
		layer.confirm("您确定要删除吗？",{btn:['确认','取消']},function(btn){
			var id = $(that).find('a').attr('data-del')+'-';
			$.ajax({
				url: "/Cart/delete.html",
				type: "POST",
				data: {id:id},
				dataType: "json",
				cache: false,
				success: function(data) {
					if(data.code==1||data.code==10004){
						layer.alert("删除成功",function(){
							window.location.href='/cart.html';					
						});	
					}else if(data.code==1004){
						layer.alert(data.msg,function(){
							window.location.href='/login/jump/cart.html';					
						});						
					}else{
						layer.alert(data.msg);
					}
				}
			});			
		});			
	})
	$(".foot_del").click(function() {
		var that = this
		var sum= '';
		$(".Each:checked").each(function() {
			sum += $(this).parents('.imfor').find("input[type='hidden']").val()+'-';
		})
		if(sum==''){
			layer.alert("请选择商品!");
			return false;
		}
		layer.confirm("您确定要删除吗？",{btn:['确认','取消']},function(btn){
			$.ajax({
				url: "/Cart/delete.html",
				type: "POST",
				data: {id:sum},
				dataType: "json",
				cache: false,
				success: function(data) {
					if(data.code==1||data.code==10004){
						layer.alert("删除成功",function(){
							window.location.href='/cart.html';					
						});	
					}else if(data.code==1004){
						layer.alert(data.msg,function(){
							window.location.href='/login/jump/cart.html';					
						});						
					}else{
						layer.alert(data.msg);
					}
				}
			});
		});
	});
	$(".submit").click(function() {
		$(".submit").attr({"disabled":"disabled"});
		$("#formData").submit();
		var index = layer.load(0, {shade: [0.5,'#ccc']}); //0代表加载的风格，支持0-2
	});
});
</script>
</body>
</html>